/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  							 script_adjust_hero_attribute.h

	$Header: /heroes4/script_adjust_hero_attribute.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( SCRIPT_ADJUST_HERO_ATTRIBUTE_H_INCLUDED )
#define SCRIPT_ADJUST_HERO_ATTRIBUTE_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "script_action_type.h"
#include "script_hero_adjustment_action.h"
#include "script_target_type.h"
#include "sized_int_types.h"
#include "creature_stack.h"

// --------------------------------------------------------------------------
// t_script_adjust_hero_attribute class
// --------------------------------------------------------------------------

class t_script_adjust_hero_attribute
	:	public t_script_hero_adjustment_action < t_uint16 >
{
public:
	// Constructor
	t_script_adjust_hero_attribute(t_stat_type attrib, int direction) 
		: m_modified_attrib(attrib), m_direction(direction), m_permanent(false) {}

	// Member functions
	bool			is_permanent() const;
	
	virtual bool	read( std::streambuf& stream, int version );
	virtual bool	read_from_map(
						std::streambuf &	stream,
						int					format_version );
	virtual bool	write( std::streambuf& stream ) const;

private:
	// Data members
	bool			m_permanent;
	t_stat_type		m_modified_attrib;
	int				m_direction;

	virtual void	make_adjustment(t_adventure_map*, t_hero* hero) const;
};

class t_script_hero_increase_defense 
	: public t_script_adjust_hero_attribute
{
public:
	t_script_hero_increase_defense() : t_script_adjust_hero_attribute(k_stat_defense, 1) {}

	virtual void	add_icons(t_basic_dialog* dialog) const;
};

class t_script_hero_decrease_defense 
	: public t_script_adjust_hero_attribute
{
public:
	t_script_hero_decrease_defense() : t_script_adjust_hero_attribute(k_stat_defense, -1) {}

	virtual void	add_icons(t_basic_dialog* dialog) const;
};

class t_script_hero_increase_speed 
	: public t_script_adjust_hero_attribute
{
public:
	t_script_hero_increase_speed() : t_script_adjust_hero_attribute(k_stat_speed, 1) {}

	virtual void	add_icons(t_basic_dialog* dialog) const;
};

class t_script_hero_decrease_speed 
	: public t_script_adjust_hero_attribute
{
public:
	t_script_hero_decrease_speed() : t_script_adjust_hero_attribute(k_stat_speed, -1) {}

	virtual void	add_icons(t_basic_dialog* dialog) const;
};

class t_script_hero_increase_max_spell_points 
	: public t_script_adjust_hero_attribute
{
public:
	t_script_hero_increase_max_spell_points() : t_script_adjust_hero_attribute(k_stat_spell_points, 1) {}

	virtual void	add_icons(t_basic_dialog* dialog) const;
};

class t_script_hero_decrease_max_spell_points 
	: public t_script_adjust_hero_attribute
{
public:
	t_script_hero_decrease_max_spell_points() : t_script_adjust_hero_attribute(k_stat_spell_points, -1) {}

	virtual void	add_icons(t_basic_dialog* dialog) const;
};

class t_script_adjust_hero_attack
	: public t_script_adjust_hero_attribute 
{
public:
	t_script_adjust_hero_attack(int direction) : t_script_adjust_hero_attribute(k_stat_attack, direction) {}

private:
	virtual void	add_icons(t_basic_dialog* dialog) const;
};

class t_script_hero_increase_attack 
	: public t_script_adjust_hero_attack
{
public:
	t_script_hero_increase_attack() : t_script_adjust_hero_attack(1) {}
};

class t_script_hero_decrease_attack 
	: public t_script_adjust_hero_attack
{
public:
	t_script_hero_decrease_attack() : t_script_adjust_hero_attack(-1) {}
};

// --------------------------------------------------------------------------
// t_script_adjust_hero_attribute inline members
// --------------------------------------------------------------------------

inline bool t_script_adjust_hero_attribute::is_permanent() const
{
	return m_permanent;
}

// --------------------------------------------------------------------------
// t_script_adjust_hero_damage_attribute inline members
// --------------------------------------------------------------------------

SPECIALIZE_SCRIPT_ACTION( k_script_action_decrease_damage, t_script_hero_decrease_attack );
SPECIALIZE_SCRIPT_ACTION( k_script_action_decrease_max_hit_points, t_script_hero_decrease_defense );
SPECIALIZE_SCRIPT_ACTION( k_script_action_decrease_max_spell_points, t_script_hero_decrease_max_spell_points );
SPECIALIZE_SCRIPT_ACTION( k_script_action_decrease_speed, t_script_hero_decrease_speed );
SPECIALIZE_SCRIPT_ACTION( k_script_action_increase_damage, t_script_hero_increase_attack );
SPECIALIZE_SCRIPT_ACTION( k_script_action_increase_max_hit_points, t_script_hero_increase_attack );
SPECIALIZE_SCRIPT_ACTION( k_script_action_increase_max_spell_points, t_script_hero_increase_max_spell_points );
SPECIALIZE_SCRIPT_ACTION( k_script_action_increase_speed, t_script_hero_increase_speed );

#endif // !defined( SCRIPT_ADJUST_HERO_ATTRIBUTE_H_INCLUDED )
